module.exports = {
  async fetch({ page, args }) {
    if ((args.keyword != '') & (args.keyword != undefined)) {
      url = `https://www.mahuaba.com/search.php?searchword=${args.keyword}`
    } else {
      url = `https://www.mahuaba.com/search.php?page=${page ||
        1}&searchtype=5&tid=${args.tid}&year=2019`
    }
    console.log('感谢@lyydhy')
    let resp = await $http.get(url)
    const $ = cheerio.load(resp.data)
    let list = $('.stui-vodlist__item', 'ul')
    let items = []
    list.each((index, li) => {
      let link = $('a', li)
      let title = $('a', li).attr('title')
      let url = `http://www.mahuaba.com${link.attr('href')}`
      items.push({
        link: url,
        style: 'vod',
        thumb: $('mip-img', li).attr('src'),
        title: title,
        route: $route('other/detail', {
          url: url
        })
      })
    })
    return {
      nextPage: (page || 1) + 1,
      items: items
    }
  }
}
